package com.demo.exception;

import javax.servlet.http.HttpServletRequest;

import com.demo.tools.ResponseData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@ControllerAdvice
@EnableWebMvc
public class GlobalExceptionHandler{

    @ExceptionHandler(AjaxException.class)
    @ResponseBody
    public ResponseData ajaxException(HttpServletRequest req, Exception e){

        return ResponseData.customerException(e.getMessage()+"; url为："+req.getRequestURI().toString());
    }


}